<%@ page language="java" import="java.util.*,com.bwsoft.admin.domain.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">

<title>优标检测网</title>
<!-- 浏览器上显示title 图标 icon图标 -->
<link type="image/x-icon" rel="icon" href="<%=basePath%>resource/img/minilogo.png">

<!-- 如果想让图标出现在收藏夹中，就：  -->
<link type="image/x-icon" rel="shortcut icon" href="<%=basePath%>resource/img/minilogo.png">
<link type="image/x-icon" rel="bookmark" href="<%=basePath%>resource/img/minilogo.png">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="优标">
<meta http-equiv="description" content="优标">
<link href="<%=basePath%>portal/css/main.css" type="text/css" rel="stylesheet">
<link href="<%=basePath%>portal/css/datepickerbootstrap.css" type="text/css" rel="stylesheet">
</head>
<body>
	<%@include file="p_head.jsp"%>
	<div class="NCContent">
		<div class="NCNewsHead">
			<div class="MainPage">
				<div class="NCMain">
					<h2 class="NCHeadWord">登录 / Login</h2>
				</div>
			</div>
		</div>
		<div class="NCNewsList">
			<div class="MainPage">
				<div class="NCMain">
					<div class="NCNewsListContent">
						<div class="QCTitleContentHead">用户登录</div>
						<div class="QCCreateBody2">
						<form action="<%=basePath%>login.action" method="post" id="loginForm">
							<div class="RegPhoneTest">
								<div class="RegPhoneTestBox">
									<span class="RegPTTitle">手机号/邮箱</span>
									<span class="RegPTContent">
										<input class="RegPTCTextS" type="text" name="account"  id="account" value="${account }"/> 
									</span> 
									<span style="display:none;" class="LoginError" id='msgAccount'>用户名或密码错误！</span>
								</div>
								<div class="RegPhoneTestBox">
									<span class="RegPTTitle">登录密码</span> 
									<span class="RegPTContent">
										<input class="RegPTCTextS" type="password" name="password"  id="password" value="${password }"/> 
									</span>
								<span style="display:none;" class="LoginError" id='msgPassword'>登陆密码不能为空！</span>
								</div>
								<div class="RegPhoneTestBox">
									<span class="RegPTTitle">验证码</span> 
									<span class="RegPTContent">
									<input class="RegPTCTextNS" type="text"  name='code' id='code'/>
									<img id="Kaptcha" src="<%=basePath%>Kaptcha.jpg" onclick="refImg()" class="LoginCode">
									<span  class="LoginError" id='msgCode' style="display:none;">验证码错误！</span>
								</div>
							</form>
							</div>
							<div class="QCCSubmitBox">
								<span class="BtnCss QCCSubmitBtn2" onclick="validate()">登录</span> <span class="BtnCss QCCSubmitBtn2 register">注册</span>
							</div>
							<div style="clear:both"></div>
						</div>
						<div class="NCNewsListContentFoot"></div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<%@include file="p_foot.jsp"%>
</body>
<script src="<%=basePath%>portal/js/res/jquery-1.4.2.min.js"></script>
<script src="<%=basePath%>portal/js/res/responsiveslides.min.js"></script>
<script src="<%=basePath%>portal/js/page/base.js"></script>
<script type="text/javascript">  
        function refImg(){  
            document.getElementById("Kaptcha").src="<%=basePath%>Kaptcha.jpg?data="+Math.random();  
        }  
        function validate(){
        	$("#msgAccount").attr("style","display:none");
        	$("#msgPassword").attr("style","display:none");
        	$("#msgCode").attr("style","display:none");
        	if(document.forms[0].account.value.trim().length==0){
        		$("#msgAccount").attr("style","display:inline");
        		$("#msgAccount").html("用户名不能为空！")
        		document.forms[0].account.focus();
        		return;
        	}
        	if(document.forms[0].password.value.trim().length==0){
        		$("#msgPassword").attr("style","display:inline");
        		$("#msgPassword").html("密码不能为空！")
        		document.forms[0].password.focus();
        		return;
        	}
        	if(document.forms[0].code.value.trim().length==0){
        		$("#msgCode").attr("style","display:inline");
        		$("#msgCode").html("验证码不能为空！")
        		document.forms[0].code.focus();
        		return;
        	}
        	$.ajax({
                cache: true,
                type: "POST",
                url:"<%=basePath%>login.action",
                data:$('#loginForm').serialize(),// 你的formid
                async: false,
                error: function(request) {
                    alert("Connection error");
                },
                success: function(data) {
                	var json = data;
					if (json.result == "0") {
						window.location="<%=basePath%>index.action";
					}
			   
					if (json.result == "1") {
						$("#msgAccount").attr("style", "display:inline");
						$("#msgAccount").html(json.msg);
						refImg();
					}
					if (json.result == "2") {
						$("#msgPassword").attr("style", "display:inline");
						$("#msgPassword").html(json.msg);
						refImg();
					}
					if (json.result == "3") {
						$("#msgCode").attr("style", "display:inline");
						$("#msgCode").html(json.msg);
						refImg();
					}
				}
			});
		}

		document.onkeydown=function(event){
            var e = event || window.event || arguments.callee.caller.arguments[0];
             if(e && e.keyCode==13){ // enter 键
             validate();
            }
        }; 
        
        $(".register").click(function() {
			location.href = "<%=basePath%>reg_step1.action";
		});
</script>  
        
</html>